import { EntitySchema } from '@mikro-orm/core';

export class LeGoods {
  id!: string;
  name!: string;
  price!: string;
  linePrice?: string;
  group!: string;
  status: number = 1;
  paramType: boolean = true;
  unit?: string;
  slideshow!: string;
  isVideo: boolean = false;
  video?: string;
  videoCover?: string;
  isReal: boolean = true;
  isSale: boolean = false;
  tags?: string;
  stocks: number = 0;
  reduceStocks: boolean = true;
  ftType: boolean = true;
  ftPrice?: string;
  ftId?: string;
  pfrStatus: boolean = false;
  pfrId?: string;
  limitBuyStatus: boolean = false;
  limitBuyType?: string;
  limitBuyValue?: number;
  minNumber: number = 1;
  sort: number = 1;
  services?: string;
  visits: number = 0;
  virtualSales: number = 0;
  sales: number = 0;
  merchantId!: string;
  AppID!: string;
  createdTime!: string;
  updatedTime?: string;
  deletedTime?: string;
  isRecycle: boolean = false;
  isDeleted: boolean = false;
  salesAmount!: string;
  isPromoter?: boolean = false;
  maxPrice?: string;
  maxProfits?: string;
}

export const LeGoodsSchema = new EntitySchema({
  class: LeGoods,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    name: { type: 'string', length: 100 },
    price: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    linePrice: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    group: { type: 'string', length: 255 },
    status: { type: 'number', columnType: 'tinyint', default: 1 },
    paramType: { type: 'boolean', default: true },
    unit: { type: 'string', length: 50, nullable: true },
    slideshow: { type: 'string', columnType: 'text' },
    isVideo: { type: 'boolean', default: false },
    video: { type: 'string', length: 8192, nullable: true },
    videoCover: { type: 'string', length: 255, nullable: true },
    isReal: { type: 'boolean', default: true },
    isSale: { type: 'boolean', default: false },
    tags: { type: 'string', length: 255, nullable: true },
    stocks: { type: 'number', default: 0 },
    reduceStocks: { type: 'boolean', default: true },
    ftType: { type: 'boolean', default: true },
    ftPrice: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    ftId: { type: 'string', columnType: 'bigint', nullable: true, index: '货运模板id' },
    pfrStatus: { type: 'boolean', default: false },
    pfrId: { type: 'string', columnType: 'bigint', nullable: true, index: '包邮规则id' },
    limitBuyStatus: { type: 'boolean', default: false },
    limitBuyType: { type: 'string', length: 50, nullable: true },
    limitBuyValue: { type: 'number', columnType: 'smallint', nullable: true },
    minNumber: { type: 'number', columnType: 'smallint', default: 1 },
    sort: { type: 'number', columnType: 'smallint', default: 1 },
    services: { type: 'string', length: 255, nullable: true },
    visits: { type: 'number', default: 0 },
    virtualSales: { type: 'number', default: 0 },
    sales: { type: 'number', default: 0 },
    merchantId: { type: 'string', columnType: 'bigint', index: '商户id' },
    AppID: { type: 'string', fieldName: 'AppID', length: 50, index: '应用id' },
    createdTime: { type: 'string', columnType: 'bigint' },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    isRecycle: { type: 'boolean', default: false },
    isDeleted: { type: 'boolean', default: false },
    salesAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    isPromoter: { type: 'boolean', nullable: true, default: false },
    maxPrice: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    maxProfits: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
  },
});
